package com.erp.myAdapter

import android.content.Context
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.BaseAdapter
import android.widget.TextView
import com.erp.bean.JijianBean
import com.erp.R
import com.erp.util.Myutil
import com.erp.view.ScrollDisabledListView
import kotlinx.android.synthetic.main.lv_jijianhuizong_item.view.*


/**
 * Created by Administrator on 2017/1/17/017.
 * 作者：刘洋
 */
class JijianhuizongAdapter(private val mlist: List<JijianBean>, private val mcontext: Context) : BaseAdapter() {
    private val minflater: LayoutInflater = LayoutInflater.from(mcontext)

    override fun getCount(): Int {
        return mlist.size
    }

    override fun getItem(position: Int): JijianBean {
        return mlist[position]
    }

    override fun getItemId(position: Int): Long {
        return position.toLong()
    }

    override fun getView(position: Int, convertView: View?, parent: ViewGroup?): View {
        var v :View
        val vh: ViewHolder
        if (convertView == null) {
            v = minflater.inflate(R.layout.lv_jijianhuizong_item, null)
            vh = ViewHolder(v)
            v.tag = vh
        } else {
            v=convertView
            vh = convertView.tag as ViewHolder
        }
        Myutil.settv(mlist[position].ws_name, vh.tvWsName)
        Myutil.settv(mlist[position].pw_project, vh.tvPwProject)
        Myutil.settv(mlist[position].jishu, vh.tvJishu)
        val jijianBean = mlist[position]
        vh.lvYuangong.isEnabled = false
        val adapter = JijianYuangongAdapter(jijianBean.members, mcontext)
        vh.lvYuangong.adapter = adapter
        return v
    }


    internal class ViewHolder(v: View) {
        var tvWsName: TextView = v.tv_ws_name
        var tvPwProject: TextView = v.tv_pw_project
        var tvJishu: TextView = v.tv_jishu
        var lvYuangong: ScrollDisabledListView = v.lv_yuangong
    }
}
